package com.ssh.action.petdiary;

import java.sql.Timestamp;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.ssh.biz.IPetdiaryBiz;
import com.ssh.biz.IPetinfoBiz;
import com.ssh.entity.Petdiary;
import com.ssh.entity.Petinfo;

@Controller
@Scope("prototype")
public class UpdateWriteAction extends ActionSupport{
	@Resource
	private IPetdiaryBiz iPetdiaryBiz;
	@Resource
	private IPetinfoBiz iPetinfoBiz;
	private Petdiary petdiary;
	private Petinfo petinfo;
	private Timestamp diaryDate;
	private String diaryTitle;
	private String diaryWeather;
	private String diaryContext;
	private String diaryIsPublic;
	private Timestamp diaryLastModify;
	private String diaryAuthor;
	private String diaryAuthorEmail;
	private int diaryId;
	private int petId;
	public String execute(){
		Map<String, Object> vcodeMap = ActionContext.getContext().getSession();
		Petinfo pet=(Petinfo)vcodeMap.get("pet");
		Petinfo petinfo = iPetinfoBiz.findPetByID(pet.getPetId());
		
		petdiary = iPetdiaryBiz.findPetdiaryByID(diaryId);
		
		petdiary.setPetinfo(petinfo);
		petdiary.setDiaryAuthor(diaryAuthor);
		petdiary.setDiaryAuthorEmail(diaryAuthorEmail);
		petdiary.setDiaryContext(diaryContext);
		petdiary.setDiaryDate(diaryDate);
		petdiary.setDiaryIsPublic(diaryIsPublic);
		petdiary.setDiaryTitle(diaryTitle);
		petdiary.setDiaryWeather(diaryWeather);
		
		iPetdiaryBiz.updatePetdiary(petdiary);
		
		return "success";
	}
	
	
	public IPetdiaryBiz getiPetdiaryBiz() {
		return iPetdiaryBiz;
	}

	public void setiPetdiaryBiz(IPetdiaryBiz iPetdiaryBiz) {
		this.iPetdiaryBiz = iPetdiaryBiz;
	}

	public IPetinfoBiz getiPetinfoBiz() {
		return iPetinfoBiz;
	}

	public void setiPetinfoBiz(IPetinfoBiz iPetinfoBiz) {
		this.iPetinfoBiz = iPetinfoBiz;
	}

	public Petdiary getPetdiary() {
		return petdiary;
	}

	public void setPetdiary(Petdiary petdiary) {
		this.petdiary = petdiary;
	}

	public Petinfo getPetinfo() {
		return petinfo;
	}

	public void setPetinfo(Petinfo petinfo) {
		this.petinfo = petinfo;
	}

	public Timestamp getDiaryDate() {
		return diaryDate;
	}

	public void setDiaryDate(Timestamp diaryDate) {
		this.diaryDate = diaryDate;
	}

	public String getDiaryTitle() {
		return diaryTitle;
	}

	public void setDiaryTitle(String diaryTitle) {
		this.diaryTitle = diaryTitle;
	}

	public String getDiaryWeather() {
		return diaryWeather;
	}

	public void setDiaryWeather(String diaryWeather) {
		this.diaryWeather = diaryWeather;
	}

	public String getDiaryContext() {
		return diaryContext;
	}

	public void setDiaryContext(String diaryContext) {
		this.diaryContext = diaryContext;
	}

	public String getDiaryIsPublic() {
		return diaryIsPublic;
	}

	public void setDiaryIsPublic(String diaryIsPublic) {
		this.diaryIsPublic = diaryIsPublic;
	}

	public Timestamp getDiaryLastModify() {
		return diaryLastModify;
	}

	public void setDiaryLastModify(Timestamp diaryLastModify) {
		this.diaryLastModify = diaryLastModify;
	}

	public String getDiaryAuthor() {
		return diaryAuthor;
	}

	public void setDiaryAuthor(String diaryAuthor) {
		this.diaryAuthor = diaryAuthor;
	}

	public String getDiaryAuthorEmail() {
		return diaryAuthorEmail;
	}

	public void setDiaryAuthorEmail(String diaryAuthorEmail) {
		this.diaryAuthorEmail = diaryAuthorEmail;
	}


	public int getDiaryId() {
		return diaryId;
	}


	public void setDiaryId(int diaryId) {
		this.diaryId = diaryId;
	}


	public int getPetId() {
		return petId;
	}


	public void setPetId(int petId) {
		this.petId = petId;
	}



	
}
